<template>
	<view class="all">
		<image class="imgtop" :src="require('@/static/img/631.png')" mode="">
			<view class="abs">
				<u-tabs active-color='#131314' :list="list" :is-scroll="false" :current="current" @change="change">
				</u-tabs>
			</view>
			<view class="boddy">
				<view style="display: flex;padding: 0rpx 10rpx 0rpx 10rpx;
				justify-content: space-between;flex-wrap: wrap;">
					<jpkc :data='item' v-for="(item,index) in toplist" 
						@onclick="submia(item)" />
				</view>
				<view class="studey" v-if="current==0">
					<view class="studey_1">
						<view class="studey_2">《前瞻与回顾》</view>
						<view class="studey_3">购买智伍汇大课继续学习</view>
					</view>
					<image src="https://s4.ax1x.com/2022/01/13/7QHcXn.png" mode="" />
				</view>
				<view style="display: flex;padding: 0rpx 10rpx 0rpx 10rpx;
				justify-content: space-between;flex-wrap: wrap;" @click="submia(item)" v-if="footlist.length>0">
					<jpkc @onclick="submia(item)" v-for="(item,index) in footlist" :data='item' />
				</view>
			</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				info: {},
				form: {
					type: 1,
					page: 1
				},
				footlist: [],
				toplist: [],
				list: [{
					name: '精品课程'
				}, {
					name: '最热课程'
				}, {
					name: '评论最多',
				}],
				current: 0
			};
		},
		onLoad() {
			this.getinfo()
		},
		methods: {
			submia(a) {
				console.log('测试')
				uni.navigateTo({
					url: `/pages/Boutique/details?cur_id=${a.cur_id}`
				});
			},
			getinfo() {
				this.$api('boutique/index', this.form).then(res => {
					this.info = res.data
					if (res.data.data.length > 4) {
						this.toplist = res.data.data.slice(0, 4)
						this.footlist = res.data.data.slice(4)
					} else {
						this.toplist = res.data.data
					}
				})
			},

			change(index) {
				this.current = index;
				this.form.type = index + 1
				this.getinfo()
			}
		}
	}
</script>

<style lang="scss">
	.studey {
		margin-bottom: 40rpx;
		padding: 0 20rpx 0 20rpx;
		width: 690rpx;
		height: 132rpx;
		background-image: url(https://s4.ax1x.com/2022/01/13/7QHUmt.png);
		background-size: 100%;
		display: flex;
		justify-content: space-between;
		align-items: center;

		image {
			width: 140rpx;
			height: 58rpx;
		}

		.studey_1 {
			.studey_2 {
				font-size: 30rpx;
				font-family: Source Han Sans CN;
				font-weight: bold;
				color: #131314;
				opacity: 1;
			}

			.studey_3 {
				font-size: 24rpx;
				font-family: Source Han Sans CN;
				font-weight: 400;
				color: #131314;
				line-height: 25px;
				opacity: 1;
			}
		}
	}

	.boddy {
		display: flex;
		flex-wrap: wrap;

		// border: 1px solid black;
		.boddyu {
			width: 48%;

			.hh {
				width: 100%;
				overflow: hidden;
				text-overflow: ellipsis;
				display: -webkit-box;
				-webkit-line-clamp: 1;
				-webkit-box-orient: vertical;
			}

			margin-bottom: 20rpx;

			.boddyu_1 {
				-webkit-box-orient: vertical;
				font-size: 32rpx;
				font-family: Source Han Sans CN;
				font-weight: bold;
				line-height: 25px;
				color: #131314;
				opacity: 1;
			}

			.boddyu_2 {
				font-size: 28rpx;
				font-family: Source Han Sans CN;
				font-weight: 400;
				line-height: 40rpx;
				color: #91969A;
				opacity: 1;
			}

			.boddyu_3 {
				text {
					color: #FF2424;
				}

				font-size: 24rpx;
				font-family: Source Han Sans CN;
				font-weight: 400;
				line-height: 30px;
				color: #131314;
				opacity: 1;
			}
		}
	}

	.images {
		width: 336rpx;
		height: 196rpx;

		.text2 {
			background-color: rgb(255, 213, 0);
			color: white;
			border-radius: 10rpx;
			padding: 3rpx 6rpx 3rpx 6rpx;
			position: relative;
			left: 20rpx;
			top: 20rpx;
		}

		.text1 {
			background-color: rgb(255, 36, 36);
			color: white;
			border-radius: 10rpx;
			padding: 3rpx 6rpx 3rpx 6rpx;
			position: relative;
			left: 20rpx;
			top: 20rpx;
		}

	}

	::v-deep .u-tab-bar {
		background-color: #FFD500 !important;
	}

	.all {
		padding: 20rpx;

		.abs {
			margin-bottom: 40rpx;
			border-bottom: 1px solid #E3E3E3;
		}

		.imgtop {
			height: 250rpx;
			width: 100%;
		}
	}
</style>
